package com.chaosj.webmagic.handler.domain;

import cn.hutool.core.text.StrFormatter;
import com.chaosj.webmagic.handler.AbstractWriterHandler;
import com.chaosj.webmagic.handler.IXPathConfig;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;

/**
 * @className: WeixinWriterHandler
 * @description:
 * @author: caoyangjie
 * @date: 2022/3/10
 **/
public class WeixinWriterHandler extends AbstractWriterHandler {
    @Override
    protected String defaultAuthor(Page page) {
        return "逅弈";
    }

    @Override
    public IXPathConfig config() {
        return new IXPathConfig() {
            @Override
            public String titleXPath() {
                return null;
            }

            @Override
            public String contentXPath() {
                return "//div[@id='js_content']";
            }

            @Override
            public String authorXPath() {
                return "//div//span[@class='rich_media_meta rich_media_meta_text']";
            }
        };
    }

    @Override
    public Site getSite() {
        return Site.me().setDomain("https://mp.weixin.qq.com");
    }
}
